﻿using System;
using System.Text;

namespace GPS.GPSLanguage
{
    public enum MessageType { GPGGA, GPGSA, GPGSV, GPRMC, GPGLL };
    

    class MessageTypeToken
    {
        public static string[] MessageTypeText = { "GPGGA", "GPGSA", "GPGSV", "GPRMC", "GPGLL" };

        public static GPSData ParseLanguage(GPSData gpsData, System.Collections.Queue q, GPSData gpsDataGSV)
        {
            String token = (string)q.Dequeue();
            
            switch(token)
            {
                case "GPGGA":
                    gpsData.SetMessageType(MessageType.GPGGA);
                    TimeToken.ParseLanguage(gpsData, q);
                    break;
                case "GPGSA":
                    gpsData.SetMessageType(MessageType.GPGSA);
                    SelectionModeToken.ParseLanguage(gpsData, q);
                    break;
                case "GPGSV":
                    gpsData = gpsDataGSV;
                    gpsData.SetMessageType(MessageType.GPGSV);
                    SentenceCountToken.ParseLanguage(gpsData, q);
                    break;
                case "GPRMC":
                    gpsData.SetMessageType(MessageType.GPRMC);
                    TimeToken.ParseLanguage(gpsData, q);
                    break;
                case "GPGLL":
                    gpsData.SetMessageType(MessageType.GPGLL);
                    LatitudeToken.ParseLanguage(gpsData, q);
                    break;
                default:
                    throw new Exception("Unsupported Message Type: " + token);
            }
            return gpsData;
        }
    }
}
